package com.itheima.grow.service.impl;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.itheima.grow.mapper.QuestionMapper;
import com.itheima.grow.model.entity.Question;
import com.itheima.grow.model.info.QuestionInfo;
import com.itheima.grow.service.IQuestionService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@Service
@Slf4j
public class QuestionServiceImpl extends ServiceImpl<QuestionMapper,Question> implements IQuestionService {


    @Resource
    private QuestionMapper questionMapper;

    @Override
    public Map<String, Object> findSmsParams(Long id) {
        return questionMapper.findSmsParams(id);
    }

    @Override
    public QuestionInfo getOne(Long id) {
        QuestionInfo q= new QuestionInfo();
        Question question = questionMapper.selectById(id);
        BeanUtils.copyProperties(question,q);
        return q;
    }

    @Override
    public List<Question> getList() {
        List<Question> list = list(Wrappers.lambdaQuery(Question.class)
                .eq(Question::getId, 1)
        );
        return list;
    }
}
